﻿using Efcore_Test.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Efcore_Test.Data.config
{
    public class LeaveConfig : IEntityTypeConfiguration<Leave>
    {
        public void Configure(EntityTypeBuilder<Leave> builder)
        {
            //单向导航属性
            builder.ToTable("T_Leave");
            builder.HasOne(x => x.Requester).WithMany().HasForeignKey(x => x.RequesterId).IsRequired(); //设置外键
            builder.HasOne(x => x.Approver).WithMany().IsRequired(false);
        }
    }
}
